# Maintainer: Felix Yan <felixonmars@archlinux.org>
# Contributor: Eric Engestrom <aur [at] engestrom [dot] ch>

pkgname=ydotool
pkgver=1.0.4
pkgrel=1
pkgdesc="Generic command-line automation tool (no X!)"
arch=('loong64' 'x86_64')
depends=('glibc')
makedepends=('cmake' 'ninja' 'scdoc' 'systemd')
url="https://github.com/ReimuNotMoe/ydotool"
license=('AGPL3')
source=("$pkgname-$pkgver.tar.gz::$url/archive/v$pkgver.tar.gz"
        "80-uinput.rules")
sha256sums=('ba075a43aa6ead51940e892ecffa4d0b8b40c241e4e2bc4bd9bd26b61fde23bd'
            'e092f5e7e474aec6c980c458046d0ff11b18750b53de2bf0a0aba1ca26e6d58e')
install=ydotool.install

build() {
  cmake \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_INSTALL_MANDIR=/usr/share/man \
    -G Ninja \
    -S "$pkgname-$pkgver" -B build
  ninja -C build
}

package() {
  DESTDIR="$pkgdir" ninja -C build install

  install -Dm644 80-uinput.rules -t "$pkgdir"/usr/lib/udev/rules.d/
}
